-- 导入所需的模块
local class = require("Utils.ClassUtils").class
local Consts = require("Data.Consts")
local MathUtils = require("Utils.MathUtils")

---@class GenerateController
---@field new fun(): GenerateController
local GenerateController = class("GenerateController")

---构造函数
function GenerateController:ctor()
	-- 初始化英雄列表
	self.offset = 3
	
end

function GenerateController:generateObjects(startPoint, objId, x, z,role)
    -- 获取起始点坐标
    local startPos = startPoint.get_position()
    local Vector3 = math.Vector3
local Quaternion = math.Quaternion
    
    -- 在x*z的网格中生成物体
    for i = 1, x do
        for j = 1, z do
            -- 计算偏移位置 (每个物体间隔1个单位)
            local offsetX = startPos.x + (j - 1) * self.offset
            local offsetZ = startPos.z + (i - 1) * self.offset
             local orientation = Quaternion(0.0, 0.0, 0.0)
    local scale = Vector3(1.0, 1.0, 1.0)
            -- 创建新位置向量
            local newPos = math.Vector3(offsetX, startPos.y, offsetZ)
            G.prefabFactory:createPrefabWithCb(Consts.PrefabType.UNIT_OBSTACLE, objId,
            newPos, math.Quaternion(0, 0, 0), scale,
            function(unit)
                
            end)
            -- local tmp=GameAPI.create_obstacle(objId, newPos, orientation, scale, role)
            -- tmp.set_physic_enable(true)
            -- tmp.set_physics_active(true)
            -- print(tmp)
        end
    end
end

return GenerateController